
#include "EquationSolver.hpp"

// implement the funciton of derived class function1.
// The action is based on EquationSolver.h to solve the roots of special equation.
// example:
//    (Temporarily omitted.)
class Function1:public Function{
public:
    double operator()(const double &x) const {
        return (x-tan(x));
    }
    void sol1()
    {
        Newton solver1((*this),4.5,10000);
        std::cout<<"(I) x0=4.5 : ";
        solver1.solve();
        std::cout<<std::endl;
    }
}f1;

// implement the funciton of derived class function2.
// The action is based on EquationSolver.h to solve the roots of special equation.
// example:
//    (Temporarily omitted.)
class Function2:public Function{
public:
    double operator()(const double &x) const {
        return (x-tan(x));
    }
    void sol2()
    {
        Newton solver2((*this),7.7,10000);
        std::cout<<"(II) x0=7.7 : ";
        solver2.solve();
        std::cout<<std::endl;
    }
}f2;

int main()
{
    std::cout<<"The Assignment C tests Newton method by x=tanx with x0=4.5 or x0=7.7."<<std::endl<<std::endl;
    f1.sol1();
    f2.sol2();
    std::cout<<"--------------------Test succeeds.--------------------"<<std::endl<<std::endl;
    return 0;
}

